home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / samapi.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-12-20  |  8.8 KB  |  205 lines

  1.  { -----------------------------------------------------------------
  2.  . samapi.pas
  3.  . interface to SAMAPI.EXE
  4.  . ----------------------------------------------------------------- }
  5.  
  6. const
  7.   DEFAULT_SAMMUX = $99; { default mux id (ah on int 0x2f to access API) }
  8.  
  9.   { API commands }
  10.   SamGetVersion       = 0;
  11.   SamSetLevel         = 1;
  12.   SamGetNumRecs       = 2;
  13.   SamGetDatabaseDate  = 3;
  14.   SamFindCall         = 4;
  15.   SamGetRecordByCall  = 5;
  16.   SamFindName         = 6;
  17.   SamGetRecordByName  = 7;
  18.   SamGetDictCode      = 8;
  19.   SamRemove           = 20;
  20.  
  21.   { API error returns }
  22.   SerrNoError         = 0;
  23.   SerrNotFound        = 1; { normal error }
  24.   SerrFail            = 2; { normal error for setlevel }
  25.   SerrBadCmd          = 3; { bad input from API caller }
  26.   SerrFatal           = 4; { SAMAPI internal error }
  27.  
  28.   { Dictionary Numbers }
  29.   DnoLastName         = 0;
  30.   DnoFirstName        = 1;
  31.   DnoAddress          = 2;
  32.   DnoCity             = 3;
  33.   DnoState            = 4;
  34.  
  35. type
  36.  
  37.  { -----------------------------------------------------------------
  38.  . datarec_t
  39.  . data records returned from/passed to SAMAPI
  40.  . ----------------------------------------------------------------- }
  41.  
  42. datarec_t = record
  43.   Cindex: longint;            { sorted by call index }
  44.   Nindex: longint;            { sorted by name index }
  45.   LastNameCode: longint;      { last name dictionary code }
  46.   FirstNameCode: longint;     { first name dict. code }
  47.   AddressCode: longint;       { address dict. code }
  48.   CityCode: longint;          { city dict. code }
  49.   StateCode: longint;         { state dict. code (note this one 16 bits) }
  50.   ZipNumber: longint;         { zip code number 0-99999 }
  51.   DobNumber: integer;         { date of birth number 0-99}
  52.   PackFlags: integer;         { bitmask of fields that are not unpacked }
  53.                                       { asciz (0 terminated strings) }
  54.   Call:       array[0..6] of char;  { call, area is always Call[2] }
  55.   Class:      array[0..1] of char;  { class, N,T,G,A, or E }
  56.   LastName:   array[0..20] of char; { last name, 20 max }
  57.   FirstName:  array[0..11] of char; { first name, 11 max }
  58.   MidInitial: array[0..1] of char;  { middle initial }
  59.   Address:    array[0..35] of char; { mailing address, 35 max }
  60.   City:       array[0..20] of char; { city, 20 max }
  61.   State:      array[0..2] of char;  { state }
  62.   Zip:        array[0..5] of char;  { zip code string }
  63.   Dob:        array[0..2] of char;  { date of birth string "00" to "99" }
  64.   reserved:   array[0..10] of char;
  65. end;
  66.  
  67.  { -----------------------------------------------------------------
  68.  . callstrings_t
  69.  . The asciz strings from a SAM datarec_t converted to pascal strings
  70.  . ----------------------------------------------------------------- }
  71.  
  72.   callstrings_t = record
  73.     Call      : string[6];
  74.     Class     : string[1];
  75.     LastName  : string[20];
  76.     FirstName : string[11];
  77.     MidInitial: string[1];
  78.     Address   : string[35];
  79.     City      : string[20];
  80.     State     : string[2];
  81.     Zip       : string[5];
  82.     Dob       : string[2];   { date of birth '00'-'99' }
  83.   end;
  84.  
  85.  
  86. { API command buffer (DS:SI) header }
  87.  
  88. chdr_t = record
  89.   cmd: byte;
  90.   fill: array[0..2] of byte;
  91. end;
  92.  
  93. { API response buffer (ES:DI) header }
  94.  
  95. rhdr_t = record
  96.     err: byte;
  97.         xerr: byte;
  98.     fill: array[0..1] of byte;
  99. end;
  100.  
  101. { API commands }
  102.                                 {--------------------------------------}
  103. { SamGetVersion       0 }
  104.     { in: }                   { chdr_t }
  105.     { out: }                  rspversion_t = record
  106.                                 h: rhdr_t;
  107.                                 version: integer;
  108.                                 level: integer;
  109.                               end;
  110.                                 {--------------------------------------}
  111.                                 { if you find a later version/level    }
  112.                                 { than you programmed for, you can chk }
  113.                                 { compat. by attempting to set level   }
  114. { SamSetLevel         1 }
  115.     { in: }                   cmdsetlevel_t = record
  116.                                 h: rhdr_t;
  117.                                 level: integer;
  118.                               end;
  119.     { out: }                  { rhdr_t }
  120.                                 {--------------------------------------}
  121.                                 { over 500k at last count and growing! }
  122. { SamGetNumRecs       2 }
  123.     { in: }                   { chdr_t }
  124.     { out: }                  rspnumrecs_t = record
  125.                                 h: rhdr_t;
  126.                                 numrecs: longint;
  127.                               end;
  128.                                 {--------------------------------------}
  129.                                 { date of data. scope is               }
  130.                                 { something like "All USA Calls" or    }
  131.                                 { "District 4" or "New York"           }
  132. { SamGetDatabaseDate  3 }
  133.     { in: }                   { chdr_t }
  134.     { out: }                  rspdbdate_t = record
  135.                                 h: rhdr_t;
  136.                                 date: array[0..9] of char; { asciz }
  137.                                 scope: array[0..24] of char; { asciz }
  138.                               end;
  139.                                 {--------------------------------------}
  140.                                 { find record containing matching call }
  141.                                 { (packflags = 0 for all unpacked)     }
  142. { SamFindCall         4 )
  143.     { in: }                   cmdfindcall_t = record
  144.                                 h: chdr_t;
  145.                                 packflags: integer;
  146.                                 call: array[0..6] of char; { asciz }
  147.                               end;
  148.     { out: }                  rspdatarec_t = record
  149.                                 h: rhdr_t;
  150.                                 d: datarec_t;
  151.                               end;
  152.                                 {--------------------------------------}
  153.                                 { get record with matching Cindex      }
  154. { SamGetRecordByCall  5 }
  155.     { in: }                   cmd_getrecs_t = record
  156.                                 h: chdr_t;
  157.                                 packflags: integer;
  158.                                 index: longint;    { Cindex (or Nindex) }
  159.                               end;
  160.     { out: }                  { rspdatarec_t }
  161.                                 {--------------------------------------}
  162.                                 { find record with matching (or close) }
  163.                                 { name                                 }
  164. { SamFindName         6 }
  165.     { in: }                   cmdfindname_t = record
  166.                                 h: chdr_t;
  167.                                 packflags: integer;
  168.                                 lastname: array[0..20] of char; { asciz }
  169.                                 firstname: array[0..11] of char; { asciz }
  170.                                 midinitial: array[0..1] of char; { asciz }
  171.                               end;
  172.     { out: }                  { rspdatarec_t }
  173.                                 {--------------------------------------}
  174.                                 { find record with matching Nindex     }
  175.                                 { NOTE: SamFindCall and                }
  176.                                 { SamGetRecordbyCall return with       }
  177.                                 { Nindex == -1                         }
  178. { SamGetRecordByName  7 }
  179.     { in: }                   { cmdgetrecs_t }
  180.     { out: }                  { rspdatarec_t }
  181.                                 {--------------------------------------}
  182.                                 { Use this to implement fast sequential}
  183.                                 { searches.  Look thru records without }
  184.                                 { unpacking them                       }
  185. { SamGetDictCode      8 }
  186.     { in: }                   cmdgetdictcode_t = record
  187.                                 h: chdr_t;
  188.                                 dno: integer;    { dictionary number }
  189.                                 astring: array[0..35] of char; {asciz}
  190.                               end;
  191.     { out: }                  rspgetdictcode_t = record
  192.                                 h: chdr_t;
  193.                                 dictcode: longint;
  194.                               end;
  195.                                 {--------------------------------------}
  196.                                 { preps SAMAPI.EXE for removal (best   }
  197.                                 { not used, do it with SAMAPI /r)      }
  198. { SamRemove          20 }
  199.     { in: }                   { chdr_t }
  200.     { out: }                  { rhdr_t }
  201.                                 {--------------------------------------}
  202.  
  203.  
  204.  
  205.